import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import inject from "@rollup/plugin-inject";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import vueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from "unplugin-auto-import/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import Components from "unplugin-vue-components/vite";
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue({
      script: {
        // 开启 defineModel
        defineModel: true,
      },
    }),
    vueDevTools(),
    AutoImport({
      imports: ["vue"],
      resolvers: [ElementPlusResolver()],
      dts: "./auto-imports.d.ts",
    }),
    Components({
      dirs: ["src/components", "src/views"],
      // 这里就是相关ui库的解析工具, 里面的选项有是否使用自动导入样式 如果需要通过 var 变量改变主题 需要注意一下
      resolvers: [
        ElementPlusResolver({
          importStyle: "sass",
        }),
      ],
      dts: "./components.d.ts",
    }),
    vueJsx({}),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
